//////////////////////////////////////////////
// UserType.js
//
//////////////////////////////////////////////

/// Class ------------------------------------


	
nkScriptsTests.UserType = class UserType extends nkDebug.TestClass
{
	static instance = new UserType ("nkScriptsTests.UserType") ;

	DataType = class DataTypeStructure
	{
		constructor ()
		{
			this._success = true ;
		}

		//create : function ()
		//{
		//	return new nkScriptsTests.UserType.DataType () ;
		//}
	}

	/*nkTests =
	{
		__testShutdown__ : function ()
		{
			nkScripts.EnvironmentManager.kill() ;
			nkScripts.ScriptManager.kill() ;
		},
		
		SetTypeGoodVisibilityFromC : function ()
		{
			const env = nkScripts.EnvironmentManager.getInstance().createOrRetrieve("env") ;
			env.setEnvironmentFor(nkScripts.INTERPRETER.LUA) ;

			nkDebug.TestUtils.check(!env.isUserTypeSet("Data"), "Type should not be set") ;
			env.setUserType("Data") ;
			nkDebug.TestUtils.check(env.isUserTypeSet("Data"), "Type should be set") ;
		},

		SetTypeNamespaceGoodVisibilityFromC : function ()
		{
			const env = nkScripts.EnvironmentManager.getInstance().createOrRetrieve("env") ;
			env.setEnvironmentFor(nkScripts.INTERPRETER.LUA) ;

			nkDebug.TestUtils.check(!env.isUserTypeSet("nkTests.Test.Data"), "Type should not be set") ;

			const type = env.setUserType("nkTests.Test.Data") ;
			nkDebug.TestUtils.check(type, "Type should be returned") ;
			nkDebug.TestUtils.check(env.isUserTypeSet("nkTests.Test.Data"), "Type should be set") ;
			nkDebug.TestUtils.check(env.getUserType("nkTests.Test.Data"), "Getter badly resolved") ;

			const nkTestsNs = env.getNamespace("nkTests") ;
			nkDebug.TestUtils.check(nkTestsNs, "nkTests not set") ;

			const testNs = nkTestsNs.getNamespace("Test") ;
			nkDebug.TestUtils.check(testNs, "Test not set") ;

			const dataType = testNs.getUserType("Data") ;
			nkDebug.TestUtils.check(dataType._ptr === type._ptr, "Wrong type out of final ns") ;
		},

		SetTypeGoodVisibilityFromLua : function ()
		{
			const env = nkScripts.EnvironmentManager.getInstance().createOrRetrieve("env") ;
			env.setEnvironmentFor(nkScripts.INTERPRETER.LUA) ;

			const script = nkScripts.ScriptManager.getInstance().createOrRetrieve("script") ;
			script.setTargetInterpreter(nkScripts.INTERPRETER.LUA) ;
			script.setSources("x = Data.new()") ;
			script.load() ;

			nkDebug.TestUtils.check(!env.execute(script), "Lua execution not failing before user type set") ;
			
			const userType = env.setUserType("Data") ;
			userType.setConstructor(nkScriptsTests.UserType.DataType.create) ;

			nkDebug.TestUtils.check(env.execute(script), "Lua execution failing after user type set") ;
		}
	}*/
}